<?php

if ($_FILES["file"]["error"] > 0) {
    echo json_encode([
        "code" => $_FILES["file"]["error"],
        "msg" => "error",
        "url" => ""
    ], 1);die;
} else {
    move_uploaded_file($_FILES["file"]["tmp_name"], time() . $_FILES["file"]["name"]);
    echo json_encode([
        "code" => 0,
        "msg" => "suc",
        "url" => time() . $_FILES["file"]["name"]
    ], 1);die;
}

die;


print_r($_FILES["file"]["type"]);
if(
    (  ($_FILES["file"]["type"] == "image/gif")
        || ($_FILES["file"]["type"] == "image/jpeg")
        || ($_FILES["file"]["type"] == "image/jpg")
        || ($_FILES["file"]["type"] == "image/png")
    ) 
    && ($_FILES["file"]["size"] < 40000)) 
{
    if ($_FILES["file"]["error"] > 0) {
        echo json_encode([
            "code" => $_FILES["file"]["error"],
            "msg" => "error",
            "url" => ""
        ], 1);die;
    } else {
        move_uploaded_file($_FILES["file"]["tmp_name"], time() . $_FILES["file"]["name"]);
        echo json_encode([
            "code" => 0,
            "msg" => "suc",
            "url" => time() . $_FILES["file"]["name"]
        ], 1);die;
    }
}
else {
    echo json_encode([
        "code" => 1,
        "msg" => "error",
        "url" => "",
    ], 1);die;
}
?>